import { ref, watch, reactive, getCurrentInstance } from 'vue'
import {Search, Plus, Upload} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import request from '@/utils/request'
import tableComp from './component/tableComp'
import $button from '@/button'
import buttonAction from './component/buttonAction'
const proxy = getCurrentInstance();
// const selectInit = ref('')

export const operationItem = reactive({
    defaultSearch: false,//默认搜索按钮
    defaultRefresh: false,//默认重置按钮
    customTableHeader: false,//
    SearchItem: [
        {
            code: 'num',
            name: '提现单号',
            type: 'input',
        },
        {
            code: 'sale',
            name: '商家名称/编号',
            type: 'input'
        },
        {
            code: 'completeFlag',
            name: '到账状态',
            type: 'select',
            options: [
                { label: '已到账', value: '1' },
                { label: '未到账', value: '0' }
            ]
        },
        {
            code: 'statusCode',
            name: '提现状态',
            type: 'select',
            options: [
                { label: '正常', value: 'normal' },
                { label: '异常', value: 'exception' }
            ]
        },
        {
            code: 'saleRoot',
            name: '所属销售',
            type: 'select',
            options: []
        },
        {
            code: ['withdrawalDateStart', 'withdrawalDateEnd'],//
            startName: "提现日期", //默认是开始时间 type为 daterange生效
            rangeName: "", //默认是至 type为 daterange生效
            endName: "提现日期", //默认是结束时间 type为 daterange生效
            valueFormat: "", //默认是YYYY-MM-DD
            placeholder: "请选择日期",//默认是请选择日期type为date生效
            type: "daterange",//daterange或date
        }
    ],
    menuArray: [
        {
            show: true,
            type: 'primary',
            text: '查询',
            icon: Search,
            handle: () => {
            }
        },
        {
            show: true,
            type: 'primary',
            text: '导出',
            hasPermi: [$button.courseorderCommissionexport|| null],
            icon: Upload,
            handle: () => {
            }
        },
    ]
})

export const tableItem = reactive({
    select: false,
    index: !true,
    tree: true,
    expandAll: true,
    align: 'center',
    column: [
        {
            label: '提现单号',
            prop: 'num',
            align: 'center',
        },
        {
            label: '提现流水号',
            prop: 'alipayNum',
            align: 'center',
            tooltip: true
        },
        {
            label: '商家名称',
            prop: 'sale',
            align: 'center',
        },
        {
            label: '提现时间',
            prop: 'submitTime',
            align: 'center',
        },
        {
            label: '提现金额(元)',
            prop: 'price',
            align: 'center',
        },
        {
            label: '提现账户',
            prop: 'withdrawalAccount',
            align: 'center',
            tooltip: true
        },
        {
            label: '到账状态',
            prop: 'completeStatus',
            align: 'center',
        },
        {
            label: '提现状态',
            prop: 'statusCode',
            align: 'center',
            component: tableComp,
            param: 'statusCode'
        },
        {
            label: '备注',
            prop: 'remark',
            align: 'center',
            tooltip: true
        },
        {
            label: '累计提现金额(元)',
            prop: 'accumulatePrice',
            align: 'center',
        },
        {
            label: '所属销售',
            prop: 'saleRoot',
            align: 'center',
        },
        {
            label: '操作',
            prop: 'action',
            align: 'center',
            component: buttonAction
        }
    ],
    pageInfo: {
        request: {
            'num': '',
            'sale': '',
            'completeFlag': '',
            'statusCode': '',
            'saleRoot': '',
            // 'withdrawalDateStart': '',
            // 'withdrawalDateEnd': '',
            'pageDomain': {
                'pageNum': '1',//分页页面数
                'pageSize': '10',//分页页面数据大小
                'orderByColumn': '',//搜索参数
                'isAsc': '',//搜索参数
                'reasonable': ''//搜索参数
            }
        },
        url: '/sale/withdrawal/paging',//分页路由，不传的话需要传入自定义的分页函数paging 传入时定义的分页函数paging会失效
        method: 'POST',//分页请求方法，不传默认为POST
        // 分页函数paging
        paging: function () {
        }
    },
    // 分页数据 自定义分页函数paging时需要把值赋给tableData
    tableData: {
        total: '',//分页总计
        // 分页数据
        data: []
    },
    // 操作栏按钮
    btnArray: [
        {
            label: '添加备注',
            type: 'primary',
            labelEn: 'status',
            show: true,
            plain: true,
            text: true,
            hasPermi: [$button.courseorderCommissionedit|| null],
            // 按钮方法
            handle: function (row) {
            }
        },
        {
            label: '修改备注',
            type: 'primary',
            labelEn: 'status',
            show: true,
            plain: true,
            text: true,
            hasPermi: [$button.courseorderCommissionedit|| null],
            // 按钮方法
            handle: function (row) {
            }
        }
    ],
    moreBtnArrayText: '',
    moreBtnArray: [],
    // 选择框触发
    selectChange: function (row) {
    },
    tableRowClassName: function (row) {
        if (row.row.statusCode === 'exception') {
            return 'warning-row';
        }
        return '';
    },
}
)
// 添加/修改备注
export function addOrEditWithdrawalRemarkApi(dataRequest) {
    return request({
        url: '/sale/withdrawal',
        method: 'PUT',
        data: dataRequest
    })
}





